﻿// =====================================================================
//
//  This file is part of the Microsoft Dynamics CRM SDK code samples.
//
//  Copyright (C) Microsoft Corporation.  All rights reserved.
//
//  This source code is intended only as a supplement to Microsoft
//  Development Tools and/or on-line documentation.  See these other
//  materials for detailed information regarding Microsoft code samples.
//
//  THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
//  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
//  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
//  PARTICULAR PURPOSE.
//
// =====================================================================

//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:4.0.21006.0
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

// 
// This code was auto-generated by Microsoft.Silverlight.ServiceReference, version 4.0.41108.0
// 
namespace SL.IdentityModel.Services
{


    [System.Diagnostics.DebuggerStepThroughAttribute()]
	[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
	[System.Runtime.Serialization.DataContractAttribute(Name = "AuthenticationService.IdentityClaim", Namespace = "http://schemas.datacontract.org/2004/07/SL.IdentityModel.Server")]
	public partial class AuthenticationServiceIdentityClaim : object, System.ComponentModel.INotifyPropertyChanged
	{

		private string IssuerField;

		private string OriginalIssuerField;

		private string TypeField;

		private string ValueField;

		private string ValueTypeField;

		[System.Runtime.Serialization.DataMemberAttribute()]
		public string Issuer
		{
			get
			{
				return this.IssuerField;
			}
			set
			{
				if ((object.ReferenceEquals(this.IssuerField, value) != true))
				{
					this.IssuerField = value;
					this.RaisePropertyChanged("Issuer");
				}
			}
		}

		[System.Runtime.Serialization.DataMemberAttribute()]
		public string OriginalIssuer
		{
			get
			{
				return this.OriginalIssuerField;
			}
			set
			{
				if ((object.ReferenceEquals(this.OriginalIssuerField, value) != true))
				{
					this.OriginalIssuerField = value;
					this.RaisePropertyChanged("OriginalIssuer");
				}
			}
		}

		[System.Runtime.Serialization.DataMemberAttribute()]
		public string Type
		{
			get
			{
				return this.TypeField;
			}
			set
			{
				if ((object.ReferenceEquals(this.TypeField, value) != true))
				{
					this.TypeField = value;
					this.RaisePropertyChanged("Type");
				}
			}
		}

		[System.Runtime.Serialization.DataMemberAttribute()]
		public string Value
		{
			get
			{
				return this.ValueField;
			}
			set
			{
				if ((object.ReferenceEquals(this.ValueField, value) != true))
				{
					this.ValueField = value;
					this.RaisePropertyChanged("Value");
				}
			}
		}

		[System.Runtime.Serialization.DataMemberAttribute()]
		public string ValueType
		{
			get
			{
				return this.ValueTypeField;
			}
			set
			{
				if ((object.ReferenceEquals(this.ValueTypeField, value) != true))
				{
					this.ValueTypeField = value;
					this.RaisePropertyChanged("ValueType");
				}
			}
		}

		public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;

		protected void RaisePropertyChanged(string propertyName)
		{
			System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
			if ((propertyChanged != null))
			{
				propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
			}
		}
	}

	[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
	[System.ServiceModel.ServiceContractAttribute(Namespace = "", ConfigurationName = "ClientProxy.AuthenticationService")]
	public interface AuthenticationService
	{

		[System.ServiceModel.OperationContractAttribute(AsyncPattern = true, Action = "urn:AuthenticationService/SignOut", ReplyAction = "urn:AuthenticationService/SignOutResponse")]
		System.IAsyncResult BeginSignOut(System.AsyncCallback callback, object asyncState);

		void EndSignOut(System.IAsyncResult result);

		[System.ServiceModel.OperationContractAttribute(AsyncPattern = true, Action = "urn:AuthenticationService/SignIn", ReplyAction = "urn:AuthenticationService/SignInResponse")]
		System.IAsyncResult BeginSignIn(System.AsyncCallback callback, object asyncState);

		System.Collections.ObjectModel.ObservableCollection<SL.IdentityModel.Services.AuthenticationServiceIdentityClaim> EndSignIn(System.IAsyncResult result);

		[System.ServiceModel.OperationContractAttribute(AsyncPattern = true, Action = "urn:AuthenticationService/SignInWithIssuedToken", ReplyAction = "urn:AuthenticationService/SignInWithIssuedTokenResponse")]
		System.IAsyncResult BeginSignInWithIssuedToken(string xmlToken, System.AsyncCallback callback, object asyncState);

		System.Collections.ObjectModel.ObservableCollection<SL.IdentityModel.Services.AuthenticationServiceIdentityClaim> EndSignInWithIssuedToken(System.IAsyncResult result);
	}

	[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
	public interface AuthenticationServiceChannel : SL.IdentityModel.Services.AuthenticationService, System.ServiceModel.IClientChannel
	{
	}

	[System.Diagnostics.DebuggerStepThroughAttribute()]
	[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
	public partial class SignInCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs
	{

		private object[] results;

		public SignInCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) :
			base(exception, cancelled, userState)
		{
			this.results = results;
		}

		public System.Collections.ObjectModel.ObservableCollection<SL.IdentityModel.Services.AuthenticationServiceIdentityClaim> Result
		{
			get
			{
				base.RaiseExceptionIfNecessary();
				return ((System.Collections.ObjectModel.ObservableCollection<SL.IdentityModel.Services.AuthenticationServiceIdentityClaim>)(this.results[0]));
			}
		}
	}

	[System.Diagnostics.DebuggerStepThroughAttribute()]
	[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
	public partial class SignInWithIssuedTokenCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs
	{

		private object[] results;

		public SignInWithIssuedTokenCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) :
			base(exception, cancelled, userState)
		{
			this.results = results;
		}

		public System.Collections.ObjectModel.ObservableCollection<SL.IdentityModel.Services.AuthenticationServiceIdentityClaim> Result
		{
			get
			{
				base.RaiseExceptionIfNecessary();
				return ((System.Collections.ObjectModel.ObservableCollection<SL.IdentityModel.Services.AuthenticationServiceIdentityClaim>)(this.results[0]));
			}
		}
	}

	[System.Diagnostics.DebuggerStepThroughAttribute()]
	[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
	public partial class AuthenticationServiceClient : System.ServiceModel.ClientBase<SL.IdentityModel.Services.AuthenticationService>, SL.IdentityModel.Services.AuthenticationService
	{

		private BeginOperationDelegate onBeginSignOutDelegate;

		private EndOperationDelegate onEndSignOutDelegate;

		private System.Threading.SendOrPostCallback onSignOutCompletedDelegate;

		private BeginOperationDelegate onBeginSignInDelegate;

		private EndOperationDelegate onEndSignInDelegate;

		private System.Threading.SendOrPostCallback onSignInCompletedDelegate;

		private BeginOperationDelegate onBeginSignInWithIssuedTokenDelegate;

		private EndOperationDelegate onEndSignInWithIssuedTokenDelegate;

		private System.Threading.SendOrPostCallback onSignInWithIssuedTokenCompletedDelegate;

		private BeginOperationDelegate onBeginOpenDelegate;

		private EndOperationDelegate onEndOpenDelegate;

		private System.Threading.SendOrPostCallback onOpenCompletedDelegate;

		private BeginOperationDelegate onBeginCloseDelegate;

		private EndOperationDelegate onEndCloseDelegate;

		private System.Threading.SendOrPostCallback onCloseCompletedDelegate;

		public AuthenticationServiceClient()
		{
		}

		public AuthenticationServiceClient(string endpointConfigurationName) :
			base(endpointConfigurationName)
		{
		}

		public AuthenticationServiceClient(string endpointConfigurationName, string remoteAddress) :
			base(endpointConfigurationName, remoteAddress)
		{
		}

		public AuthenticationServiceClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) :
			base(endpointConfigurationName, remoteAddress)
		{
		}

		public AuthenticationServiceClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) :
			base(binding, remoteAddress)
		{
		}

		public System.Net.CookieContainer CookieContainer
		{
			get
			{
				System.ServiceModel.Channels.IHttpCookieContainerManager httpCookieContainerManager = this.InnerChannel.GetProperty<System.ServiceModel.Channels.IHttpCookieContainerManager>();
				if ((httpCookieContainerManager != null))
				{
					return httpCookieContainerManager.CookieContainer;
				}
				else
				{
					return null;
				}
			}
			set
			{
				System.ServiceModel.Channels.IHttpCookieContainerManager httpCookieContainerManager = this.InnerChannel.GetProperty<System.ServiceModel.Channels.IHttpCookieContainerManager>();
				if ((httpCookieContainerManager != null))
				{
					httpCookieContainerManager.CookieContainer = value;
				}
				else
				{
					throw new System.InvalidOperationException("Unable to set the CookieContainer. Please make sure the binding contains an HttpC" +
							"ookieContainerBindingElement.");
				}
			}
		}

		public event System.EventHandler<System.ComponentModel.AsyncCompletedEventArgs> SignOutCompleted;

		public event System.EventHandler<SignInCompletedEventArgs> SignInCompleted;

		public event System.EventHandler<SignInWithIssuedTokenCompletedEventArgs> SignInWithIssuedTokenCompleted;

		public event System.EventHandler<System.ComponentModel.AsyncCompletedEventArgs> OpenCompleted;

		public event System.EventHandler<System.ComponentModel.AsyncCompletedEventArgs> CloseCompleted;

		[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
		System.IAsyncResult SL.IdentityModel.Services.AuthenticationService.BeginSignOut(System.AsyncCallback callback, object asyncState)
		{
			return base.Channel.BeginSignOut(callback, asyncState);
		}

		[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
		void SL.IdentityModel.Services.AuthenticationService.EndSignOut(System.IAsyncResult result)
		{
			base.Channel.EndSignOut(result);
		}

		private System.IAsyncResult OnBeginSignOut(object[] inValues, System.AsyncCallback callback, object asyncState)
		{
			return ((SL.IdentityModel.Services.AuthenticationService)(this)).BeginSignOut(callback, asyncState);
		}

		private object[] OnEndSignOut(System.IAsyncResult result)
		{
			((SL.IdentityModel.Services.AuthenticationService)(this)).EndSignOut(result);
			return null;
		}

		private void OnSignOutCompleted(object state)
		{
			if ((this.SignOutCompleted != null))
			{
				InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
				this.SignOutCompleted(this, new System.ComponentModel.AsyncCompletedEventArgs(e.Error, e.Cancelled, e.UserState));
			}
		}

		public void SignOutAsync()
		{
			this.SignOutAsync(null);
		}

		public void SignOutAsync(object userState)
		{
			if ((this.onBeginSignOutDelegate == null))
			{
				this.onBeginSignOutDelegate = new BeginOperationDelegate(this.OnBeginSignOut);
			}
			if ((this.onEndSignOutDelegate == null))
			{
				this.onEndSignOutDelegate = new EndOperationDelegate(this.OnEndSignOut);
			}
			if ((this.onSignOutCompletedDelegate == null))
			{
				this.onSignOutCompletedDelegate = new System.Threading.SendOrPostCallback(this.OnSignOutCompleted);
			}
			base.InvokeAsync(this.onBeginSignOutDelegate, null, this.onEndSignOutDelegate, this.onSignOutCompletedDelegate, userState);
		}

		[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
		System.IAsyncResult SL.IdentityModel.Services.AuthenticationService.BeginSignIn(System.AsyncCallback callback, object asyncState)
		{
			return base.Channel.BeginSignIn(callback, asyncState);
		}

		[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
		System.Collections.ObjectModel.ObservableCollection<SL.IdentityModel.Services.AuthenticationServiceIdentityClaim> SL.IdentityModel.Services.AuthenticationService.EndSignIn(System.IAsyncResult result)
		{
			return base.Channel.EndSignIn(result);
		}

		private System.IAsyncResult OnBeginSignIn(object[] inValues, System.AsyncCallback callback, object asyncState)
		{
			return ((SL.IdentityModel.Services.AuthenticationService)(this)).BeginSignIn(callback, asyncState);
		}

		private object[] OnEndSignIn(System.IAsyncResult result)
		{
			System.Collections.ObjectModel.ObservableCollection<SL.IdentityModel.Services.AuthenticationServiceIdentityClaim> retVal = ((SL.IdentityModel.Services.AuthenticationService)(this)).EndSignIn(result);
			return new object[] {
                    retVal};
		}

		private void OnSignInCompleted(object state)
		{
			if ((this.SignInCompleted != null))
			{
				InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
				this.SignInCompleted(this, new SignInCompletedEventArgs(e.Results, e.Error, e.Cancelled, e.UserState));
			}
		}

		public void SignInAsync()
		{
			this.SignInAsync(null);
		}

		public void SignInAsync(object userState)
		{
			if ((this.onBeginSignInDelegate == null))
			{
				this.onBeginSignInDelegate = new BeginOperationDelegate(this.OnBeginSignIn);
			}
			if ((this.onEndSignInDelegate == null))
			{
				this.onEndSignInDelegate = new EndOperationDelegate(this.OnEndSignIn);
			}
			if ((this.onSignInCompletedDelegate == null))
			{
				this.onSignInCompletedDelegate = new System.Threading.SendOrPostCallback(this.OnSignInCompleted);
			}
			base.InvokeAsync(this.onBeginSignInDelegate, null, this.onEndSignInDelegate, this.onSignInCompletedDelegate, userState);
		}

		[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
		System.IAsyncResult SL.IdentityModel.Services.AuthenticationService.BeginSignInWithIssuedToken(string xmlToken, System.AsyncCallback callback, object asyncState)
		{
			return base.Channel.BeginSignInWithIssuedToken(xmlToken, callback, asyncState);
		}

		[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
		System.Collections.ObjectModel.ObservableCollection<SL.IdentityModel.Services.AuthenticationServiceIdentityClaim> SL.IdentityModel.Services.AuthenticationService.EndSignInWithIssuedToken(System.IAsyncResult result)
		{
			return base.Channel.EndSignInWithIssuedToken(result);
		}

		private System.IAsyncResult OnBeginSignInWithIssuedToken(object[] inValues, System.AsyncCallback callback, object asyncState)
		{
			string xmlToken = ((string)(inValues[0]));
			return ((SL.IdentityModel.Services.AuthenticationService)(this)).BeginSignInWithIssuedToken(xmlToken, callback, asyncState);
		}

		private object[] OnEndSignInWithIssuedToken(System.IAsyncResult result)
		{
			System.Collections.ObjectModel.ObservableCollection<SL.IdentityModel.Services.AuthenticationServiceIdentityClaim> retVal = ((SL.IdentityModel.Services.AuthenticationService)(this)).EndSignInWithIssuedToken(result);
			return new object[] {
                    retVal};
		}

		private void OnSignInWithIssuedTokenCompleted(object state)
		{
			if ((this.SignInWithIssuedTokenCompleted != null))
			{
				InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
				this.SignInWithIssuedTokenCompleted(this, new SignInWithIssuedTokenCompletedEventArgs(e.Results, e.Error, e.Cancelled, e.UserState));
			}
		}

		public void SignInWithIssuedTokenAsync(string xmlToken)
		{
			this.SignInWithIssuedTokenAsync(xmlToken, null);
		}

		public void SignInWithIssuedTokenAsync(string xmlToken, object userState)
		{
			if ((this.onBeginSignInWithIssuedTokenDelegate == null))
			{
				this.onBeginSignInWithIssuedTokenDelegate = new BeginOperationDelegate(this.OnBeginSignInWithIssuedToken);
			}
			if ((this.onEndSignInWithIssuedTokenDelegate == null))
			{
				this.onEndSignInWithIssuedTokenDelegate = new EndOperationDelegate(this.OnEndSignInWithIssuedToken);
			}
			if ((this.onSignInWithIssuedTokenCompletedDelegate == null))
			{
				this.onSignInWithIssuedTokenCompletedDelegate = new System.Threading.SendOrPostCallback(this.OnSignInWithIssuedTokenCompleted);
			}
			base.InvokeAsync(this.onBeginSignInWithIssuedTokenDelegate, new object[] {
                        xmlToken}, this.onEndSignInWithIssuedTokenDelegate, this.onSignInWithIssuedTokenCompletedDelegate, userState);
		}

		private System.IAsyncResult OnBeginOpen(object[] inValues, System.AsyncCallback callback, object asyncState)
		{
			return ((System.ServiceModel.ICommunicationObject)(this)).BeginOpen(callback, asyncState);
		}

		private object[] OnEndOpen(System.IAsyncResult result)
		{
			((System.ServiceModel.ICommunicationObject)(this)).EndOpen(result);
			return null;
		}

		private void OnOpenCompleted(object state)
		{
			if ((this.OpenCompleted != null))
			{
				InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
				this.OpenCompleted(this, new System.ComponentModel.AsyncCompletedEventArgs(e.Error, e.Cancelled, e.UserState));
			}
		}

		public void OpenAsync()
		{
			this.OpenAsync(null);
		}

		public void OpenAsync(object userState)
		{
			if ((this.onBeginOpenDelegate == null))
			{
				this.onBeginOpenDelegate = new BeginOperationDelegate(this.OnBeginOpen);
			}
			if ((this.onEndOpenDelegate == null))
			{
				this.onEndOpenDelegate = new EndOperationDelegate(this.OnEndOpen);
			}
			if ((this.onOpenCompletedDelegate == null))
			{
				this.onOpenCompletedDelegate = new System.Threading.SendOrPostCallback(this.OnOpenCompleted);
			}
			base.InvokeAsync(this.onBeginOpenDelegate, null, this.onEndOpenDelegate, this.onOpenCompletedDelegate, userState);
		}

		private System.IAsyncResult OnBeginClose(object[] inValues, System.AsyncCallback callback, object asyncState)
		{
			return ((System.ServiceModel.ICommunicationObject)(this)).BeginClose(callback, asyncState);
		}

		private object[] OnEndClose(System.IAsyncResult result)
		{
			((System.ServiceModel.ICommunicationObject)(this)).EndClose(result);
			return null;
		}

		private void OnCloseCompleted(object state)
		{
			if ((this.CloseCompleted != null))
			{
				InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
				this.CloseCompleted(this, new System.ComponentModel.AsyncCompletedEventArgs(e.Error, e.Cancelled, e.UserState));
			}
		}

		public void CloseAsync()
		{
			this.CloseAsync(null);
		}

		public void CloseAsync(object userState)
		{
			if ((this.onBeginCloseDelegate == null))
			{
				this.onBeginCloseDelegate = new BeginOperationDelegate(this.OnBeginClose);
			}
			if ((this.onEndCloseDelegate == null))
			{
				this.onEndCloseDelegate = new EndOperationDelegate(this.OnEndClose);
			}
			if ((this.onCloseCompletedDelegate == null))
			{
				this.onCloseCompletedDelegate = new System.Threading.SendOrPostCallback(this.OnCloseCompleted);
			}
			base.InvokeAsync(this.onBeginCloseDelegate, null, this.onEndCloseDelegate, this.onCloseCompletedDelegate, userState);
		}

		protected override SL.IdentityModel.Services.AuthenticationService CreateChannel()
		{
			return new AuthenticationServiceClientChannel(this);
		}

		private class AuthenticationServiceClientChannel : ChannelBase<SL.IdentityModel.Services.AuthenticationService>, SL.IdentityModel.Services.AuthenticationService
		{

			public AuthenticationServiceClientChannel(System.ServiceModel.ClientBase<SL.IdentityModel.Services.AuthenticationService> client) :
				base(client)
			{
			}

			public System.IAsyncResult BeginSignOut(System.AsyncCallback callback, object asyncState)
			{
				object[] _args = new object[0];
				System.IAsyncResult _result = base.BeginInvoke("SignOut", _args, callback, asyncState);
				return _result;
			}

			public void EndSignOut(System.IAsyncResult result)
			{
				object[] _args = new object[0];
				base.EndInvoke("SignOut", _args, result);
			}

			public System.IAsyncResult BeginSignIn(System.AsyncCallback callback, object asyncState)
			{
				object[] _args = new object[0];
				System.IAsyncResult _result = base.BeginInvoke("SignIn", _args, callback, asyncState);
				return _result;
			}

			public System.Collections.ObjectModel.ObservableCollection<SL.IdentityModel.Services.AuthenticationServiceIdentityClaim> EndSignIn(System.IAsyncResult result)
			{
				object[] _args = new object[0];
				System.Collections.ObjectModel.ObservableCollection<SL.IdentityModel.Services.AuthenticationServiceIdentityClaim> _result = ((System.Collections.ObjectModel.ObservableCollection<SL.IdentityModel.Services.AuthenticationServiceIdentityClaim>)(base.EndInvoke("SignIn", _args, result)));
				return _result;
			}

			public System.IAsyncResult BeginSignInWithIssuedToken(string xmlToken, System.AsyncCallback callback, object asyncState)
			{
				object[] _args = new object[1];
				_args[0] = xmlToken;
				System.IAsyncResult _result = base.BeginInvoke("SignInWithIssuedToken", _args, callback, asyncState);
				return _result;
			}

			public System.Collections.ObjectModel.ObservableCollection<SL.IdentityModel.Services.AuthenticationServiceIdentityClaim> EndSignInWithIssuedToken(System.IAsyncResult result)
			{
				object[] _args = new object[0];
				System.Collections.ObjectModel.ObservableCollection<SL.IdentityModel.Services.AuthenticationServiceIdentityClaim> _result = ((System.Collections.ObjectModel.ObservableCollection<SL.IdentityModel.Services.AuthenticationServiceIdentityClaim>)(base.EndInvoke("SignInWithIssuedToken", _args, result)));
				return _result;
			}
		}
	}
}
